Every programming language has data type. To identify what kind of value is stored in a variable. As an example we can explain it like $x=10; that means value of $x is 10. This is integer(whole number) value. Data type help to identify what kind of data which is in a variable like integer or string or float data type.

We?ve already notice it that variable automatically trace correct data type according to its value. It called Type Juggling. So, $x=10; means that $x is integer, $x=?CreativeMission? means $x is string and $x=10.5 is float data type etc. We?ve explained PHP data type in bellow...

1. Boolean: this data have two values True and False. There are many functions which one return Boolean. To check the value of Boolean data in a variable we can use is_bool() function like bellow.

 
<?php
$x = TRUE;
$y = 9;
var_dump(is_bool($y));// output bool(false)
var_dump(is_bool($x));// output bool(true)
?>

After checking the value of $y, we have found output false because this variable value is integer or whole number. So, we can check the value of every variable like this.

2. Integer: It supports whole number without decimal places just like 1,5,4,9 or -1,-5,-9 etc. To check the value of integer data or not in a variable we can use is_int() function like bellow. If it is integer then show True and otherwise it will show false.  
<?php
$x = 1011100; //binary number 92
var_dump($x);
?>
Output: int(1011100)
3. Float: Float data like 9.23 is float number or double or real number.

 
<?php
$x = 9.2054;
var_dump($x);
?>
Output: Float(9.2054)

4. String: String means any word or letter which one is in single quotation and double quotation like..

 
<?php

$x=?Creative Mission?;

?> 


All Tutorial => 12345678910





Write Comment